package demo.practice.leetcode_offer;

public class Offer04 {

    public static void main(String[] args) {
        Offer04 offer04= new Offer04();
        offer04.findNumberIn2DArray(new int[][]{{-5}},-5);
    }

    public boolean findNumberIn2DArray(int[][] matrix, int target) {

        //方法1 每行   二分法
        //方法2  右下角的点   

        int i = matrix.length - 1;
        int j = 0;

        while (i >= 0 && j < matrix[0].length) {
            if (matrix[i][j] > target) {
                i--;
            } else if (matrix[i][j] < target) {
                j++;
            } else {
                return true;
            }
        }

        return false;
    }

}
